<template>
	<view class="grid col-3 text-center solids-top">
		<view class="solids-right solids-bottom padding flex align-center justify-center" @click="navigateTo('/pages/admin/modelAdd')">
			<view class="text-sl text-blue">
				<text class="cuIcon-add"></text>
			</view>
		</view>
		<view @tap="clickDelete(item._id)" v-for="(item,index) in list" :key="index" :class="(index+2)%3!=0?'solids-right ':''" class="solids-bottom padding-xs flex flex-direction">
			<image :src="item.img" mode="widthFix" />
			<view class="padding-xs">{{item.name}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				rowsNumber:0,
				list:[]
			};
		},
		onShow(){
			this._getList();
		},
		methods:{
			_getList(){
				this.$u.api.admin_modelList({rowsPerPage:1000}).then(data => {
					this.rowsNumber=data.rowsNumber;
					this.list=data.list;
					console.log(data);
				})
			},
			navigateTo(url){
				uni.navigateTo({
					url:url
				})
			},
			clickDelete(_id){
				uni.showModal({
				    title: '确认删除',
				    content: '您确认要删除这个预设型号么？',
				    success: (res)=> {
				        if (res.confirm) {
				            this.$u.api.admin_modelDelete({_id:_id}).then(data => {
				            	this._getList();
				            })
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>

<style lang="scss">

</style>
